<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>

        // function Person() {
        //     this.name = "name";
        //     this.age = 0;
        // }

        // function Student() {

        // }

        // Student.prototype = new Person();

        // var stu = new Student();
        // console.log(stu);

        class Person {
            constructor(name, age) {
                this.name = name;
                this.age = age;
            }

            sayHi(){
                console.log("Hey, Nigger");
            }
        }

        class Student extends Person{
            constructor(name, age){
                //super就是用来调用构造函数的
                //调用父类构造函数的目的，其实就是为了获取父类中的属性
                //super是必须调用，不调用会报错
                super(name, age);
                this.stuNo = 10086;
            }
        }


        var stu = new Student("zcm", 18);
        console.log(stu);
        
    </script>
</body>

</html>